package com.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcDao {
	
	static Connection conn =null;
	
	private static String driverClass = "com.mysql.jdbc.Driver";
	private static String url = "jdbc:mysql://localhost:3306/user?useUnicode=true&characterEncoding=UTF-8";
	static String user = "root";
	private static String password = "root";
	
    
    public static Connection connection() throws SQLException, ClassNotFoundException {
    	Class.forName(driverClass);
		conn = DriverManager.getConnection(url, user, password);
		return conn;
    }
    
    public static void close(Statement stat,Connection conn) throws SQLException{
		if(stat!=null){
	    	   stat.close();
	    }
	    if(conn!=null){
	    	   conn.close();
	    }
	}



	public JdbcDao() {
		// TODO Auto-generated constructor stub
	}
public static void main(String[] args) throws ClassNotFoundException, SQLException {
	System.out.println(JdbcDao.connection());
}
}
